#ifndef ERRORHANDLERS_H
#define ERRORHANDLERS_H

namespace Cvekas {

/// Error checking macro for methods returning HRESULT. Outputs error to log.
#define E_L(func) \
{ \
	HRESULT hr = (func); \
	if(FAILED(hr)) \
	{ \
		LOG(FORMAT(#func " failed, return value: %X", % hr)); \
	} \
}

/// Error checking macro for methods returning HRESULT. On error throws Exception.
#define E_E(func) \
{ \
	HRESULT hr = (func); \
	if(FAILED(hr)) \
	{ \
		throw EXCEPTION(FORMAT(#func " failed, return value: %X", % hr)); \
	} \
}

/// Converts HRESULT to bool indicating if method succeeded.
inline bool E_B(HRESULT hr) 
{
	return SUCCEEDED(hr);
}

} // namespace

#endif